use text_search::retrieval;
use clap::Parser;

#[derive(Parser, Debug)]
#[command(author, version, about="文本内容搜索工具", long_about = None)]
struct Args {

    /// 正则表示工具
    #[arg(short='r', long="regex", action=clap::ArgAction::SetTrue, help="正则表达式搜索")]
    regex: bool,

    /// 存放两个参数：p0=待搜索的目录，p1=搜索内容
    #[arg(required = true )]
    params: Vec<String>,

}

fn main() {

    // 解析命令行参数
    let args = Args::parse();
    println!("args = {:?}", args);

    assert_eq!(args.params.len(), 2);

    let dir = &args.params[0];
    let text = &args.params[1];
    retrieval::run(dir, text, args.regex);
}
